package com.example.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.entity.Diring;
import com.example.service.diringService;
import com.example.util.Code;
import com.example.util.Result;

import com.example.util.page1;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/s/diring")
public class diringController {

    @Autowired
    private diringService diringService;

    //驾驶证分页查询
    @RequestMapping("/findpage")
    public Result findByPara(@RequestBody page1 Diring) {
        Page<Map> byParams = diringService.findpage(Diring);
        if (byParams != null) {
            return new Result(Code.GET_OK, byParams, "查询成功");
        } else {
            return new Result(Code.GET_ERR, "查询失败");
        }
    }
    //根据id查询驾驶证全部
    @RequestMapping("/findAll/{id}")
    public Result findById(@PathVariable Integer id){
        Diring byId = diringService.findById(id);
        if (byId!=null){
            return new Result(Code.GET_OK,byId, "查询成功");
        }else {
            return new Result(Code.GET_ERR,"查询失败");
        }
    }

}
